// pages/expert/common/courseList.js
const Controller = require('../../controllers/controllers.js').controller;
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    authorId:{
      type:Number,
      vaule:''
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    list:[],
    page:1,
    pageSize:10,
    lastPage:false
  },

  /**
   * 组件的方法列表
   */
  methods: {
    //获取列表
    lessonlist(){
      Controller.lessonlist({
        authorId:this.properties.authorId,
        page:this.data.page,
        pageSize:this.data.pageSize
      }).then(res=>{
        if(res.code==0){
          let list = this.data.list
          list = list.concat(res.data.baseData.list)
          let lastPage = res.data.baseData.lastPage
          this.setData({
            list,
            lastPage
          })
        }
      })
    },
    //分页
    load(){
      if(this.data.lastPage){
        return
      }
      this.setData({
        page:this.data.page+1
      })
      this.lessonlist()
    },

    //跳转
    goDetails(e) {
      let id = e.currentTarget.dataset["id"]
      id = Number(id)
      if(id==0)return;
      wx.navigateTo({ url: '/pages/videoDetails/videoDetails?id=' + id });
    },
  },

  ready: function () {
    this.lessonlist()
  }
})
